package com.quad.innovators.salesease.config;

import org.springdoc.core.models.GroupedOpenApi;
import org.springdoc.core.properties.SpringDocConfigProperties;
import org.springdoc.core.properties.SwaggerUiConfigProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
public class SpringDocConfig {

    @Bean
    @Primary
    public SwaggerUiConfigProperties swaggerUiConfig() {
        SwaggerUiConfigProperties properties = new SwaggerUiConfigProperties();
        properties.setPath("/swagger-ui.html");
        properties.setTagsSorter("alpha");
        properties.setOperationsSorter("alpha");
        return properties;
    }

    @Bean
    public GroupedOpenApi defaultGroupOpenApi() {
        return GroupedOpenApi.builder()
                .group("default")
                .pathsToMatch("/**")
                .packagesToScan("com.quad.innovators.salesease")
                .build();
    }

    @Bean
    @Primary
    public SpringDocConfigProperties springDocConfigProperties() {
        SpringDocConfigProperties properties = new SpringDocConfigProperties();
        properties.getApiDocs().setPath("/v3/api-docs");
        return properties;
    }
}
